package com.jblog.core.model;

import java.sql.Timestamp;

import com.jblog.Constants;
import com.jblog.common.util.Memory;
import com.jblog.core.model.account.Account;

/**
 * Base Model
 */
public class BaseModel implements java.io.Serializable {

	private static final long serialVersionUID = 1L;

	private Long id;
	private Timestamp createTime = new Timestamp(System.currentTimeMillis());
	private Timestamp lastUpdTime = new Timestamp(System.currentTimeMillis());
	private String lastUpdBy = getCurrentUser();
	
	public BaseModel() {
    }

    public BaseModel(Long id) {
        this.id = id;
    }

    public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Timestamp getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Timestamp createTime) {
		this.createTime = createTime;
	}

	public Timestamp getLastUpdTime() {
		return lastUpdTime;
	}

	public void setLastUpdTime(Timestamp lastUpdTime) {
		this.lastUpdTime = lastUpdTime;
	}

	public String getLastUpdBy() {
		return lastUpdBy;
	}

	public void setLastUpdBy(String lastUpdBy) {
		this.lastUpdBy = lastUpdBy;
	}
	
	private String getCurrentUser() {
	    Account account = Memory.get(Constants.System.CURRENT_USER);
	    return null == account ? "" : account.getName();
	}
}
